
import 'package:flutter/material.dart';
import 'package:mvvmdemo/common/appglabaldata.dart';
import 'package:mvvmdemo/viewmodel/buiness/saleviewmodel.dart';
import 'package:mvvmdemo/viewmodel/state/appmodel.dart';
import 'package:provider/provider.dart';

class SaleView extends StatelessWidget{
  const SaleView({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Consumer<AppModel>(
        builder:(_, appModel, child) {
          AppModel _appModel = appModel;
          return
            Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text("用户名:" +AppGlabalData.userDataModel!.data!.operuser!.gh.toString()),
                Text("商品名称:${null!=_appModel&&null!=_appModel.orderModel&&null!=_appModel.orderModel!.data&&null!=_appModel.orderModel!.data!.order&&null!=_appModel.orderModel!.data!.order!.goodsList&&_appModel.orderModel!.data!.order!.goodsList!.isNotEmpty? _appModel.orderModel!.data!.order!.goodsList![_appModel.orderModel!.data!.order!.goodsList!.length-1].goodsName.toString():''}"),
                TextButton(
                    onPressed: () {
                      SaleViewModel.getSaleViewModel()!.findGoods1(context);
                    },
                    child: const Text("查找商品1")
                ),
                TextButton(
                    onPressed: () {
                      SaleViewModel.getSaleViewModel()!.findGoods2(context);
                    },
                    child: const Text("查找商品2")
                ),
                TextButton(
                    onPressed: () {

                      SaleViewModel.getSaleViewModel()!.back(context);

                    },
                    child: const Text("返回")
                ),
              ],
            );
        },
    );
  }
}

